package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.PersonalRiziListModel;

/**
 * @author liyc
 * @time 2012-3-13 下午2:34:42
 * @annotation 日志列表获取任务
 */
public class PersonalRizhiListTask extends Task {

	public PersonalRizhiListTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		int year = (Integer) getParam().get("year");
		int month = (Integer) getParam().get("month");
		String seamurl = getCon().fp.generateUrl("EpointGetRizhiListInfo_2",getCon().fp.getUserguid(),year+"",month+"");
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}

	public static List<PersonalRiziListModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<PersonalRiziListModel> plist = new ArrayList<PersonalRiziListModel>();
		for (int i = 0; i < focs.size(); i++) {
			PersonalRiziListModel mt = new PersonalRiziListModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("psdate") != null)
				mt.psdate = foc.elementText("psdate");
			if (foc.element("ldps") != null)
				mt.ldps = foc.elementText("ldps");
			if (foc.element("rzdate") != null)
				mt.rzdate = foc.elementText("rzdate");
			if (foc.element("chuchai") != null)
				mt.chuchai = foc.elementText("chuchai");
			if (foc.element("islv") != null)
				mt.islv = foc.elementText("islv");
			if (foc.element("status") != null)
				mt.status = foc.elementText("status");
			if (foc.element("isqj") != null)
				mt.isqj = foc.elementText("isqj");
			if (foc.element("shzt") != null)
				mt.shzt = foc.elementText("shzt");
			if (foc.element("cczt") != null)
				mt.cczt = foc.elementText("cczt");
			if (foc.element("psryguid") != null)
				mt.psryguid = foc.elementText("psryguid");
			if (foc.element("psryname") != null)
				mt.psryname = foc.elementText("psryname");
			if (foc.element("gzrzguid") != null)
				mt.gzrzguid = foc.elementText("gzrzguid");
			if (foc.element("ccguid") != null)
				mt.ccguid = foc.elementText("ccguid");
			if (foc.element("lyguid") != null)
				mt.lyguid = foc.elementText("lyguid");
			if (foc.element("qjguid") != null)
				mt.qjguid = foc.elementText("qjguid");
			if (foc.element("chuchaisj") != null)
				mt.chuchaisj = foc.elementText("chuchaisj");
			plist.add(mt);
		}

		/*for(int i=0;i<plist.size();i++){
			PersonalRiziListModel prm = plist.get(i);
			String status = prm.status;
			String psdate = prm.psdate;
			String ldps = prm.ldps;
			if("".equals(psdate)&&"".equals(status)){
				prm.shzt = "未提交";
			}
			else if("".equals(psdate)&&"1".equals(status)){
				prm.shzt = "已填";
			}
			else if(!"".equals(psdate)&&"".equals(ldps)){
				prm.shzt = "已审";
			}
			else if(!"".equals(ldps)&&ldps!=null){
				prm.shzt = "评审结果";
			}
			else{
				prm.shzt = "";
			}

			String chuchai = (String) prm.chuchai;
			String islv = (String) prm.islv;
			String isqj =  (String) prm.isqj;

			if("1".equals(chuchai)){
				prm.cczt = "出差";
			}
			else if("1".equals(islv)){
				prm.cczt = "旅游";
			}
			else if("1".equals(isqj)){
				prm.cczt = "请假";
			}
			else{
				prm.cczt = "";
			}

			plist.set(i, prm);
		}*/
		return plist;
	}

}
